package io.tij;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.regex.Pattern;

public class DirList3 {

	public static void main(final String[] args){
		
		File file = new File(".");
		String[] list = null;
		
		if(args.length == 0)
			list = file.list();
		else
			list = file.list(new FilenameFilter() {
				Pattern pattern = Pattern.compile(args[0]);
				public boolean accept(File dir, String name) {
					return pattern.matcher(name).matches();
				}
			});
		
		Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
		for(String item : list){
			System.out.println(item);
		}
	}
}